﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ControllerSpecific.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Title"] = "Home Page";
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }

        public ActionResult About()
        {
            ViewData["Title"] = "About";
            return View();
        }

        protected override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            ViewResult result = filterContext.Result as ViewResult;
            if (result != null)
            {
                string title = (string)result.ViewData["Title"];
                if (!String.IsNullOrEmpty(title))
                    title = "Home - " + title;
                else
                    title = "Home";
                result.ViewData["Title"] = title;
            }
            base.OnActionExecuted(filterContext);
        }
    }
}
